# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=wordpress-exploit-framework
pkgver=v2.0.1.r7.ge55ded4
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation')
pkgdesc='A Ruby framework for developing and using modules which aid in the penetration testing of WordPress powered websites and systems.'
arch=('any')
url='https://github.com/rastating/wordpress-exploit-framework'
license=('GPL3')
depends=('ruby' 'ruby-bundler' 'libxslt')
makedepends=('git')
source=("git+https://github.com/rastating/$pkgname.git")
install="$pkgname.install"
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/wpxf" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ./bin/wpxf "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/wpxf"
}

